3D Graphics Programming with QuickDraw 3D 1.5.4
Previous | QD3D Book | Overview | Chapter Contents | Next |
Once you written all the necessary public and private draw context methods, as well as methods to handle textures and bitmaps, you must write a TQAEngineGetMethod method that reports the addresses of some of those methods to QuickDraw 3D RAVE. Listing 14 shows a sample TQAEngineGetMethod method. Notice that this method returns the addresses only of the private draw context methods and the methods to handle textures and bitmaps. The pointers for the public draw context methods are assigned directly to the fields of a draw context structure by your TQADrawPrivateNew method (as shown in Listing 11 ).
Listing 14 A TQAEngineGetMethod method
TQAError MyEngineGetMethod (TQAEngineMethodTag methodTag, TQAEngineMethod *method)
{
switch (methodTag) {
case kQADrawPrivateNew:
method->drawPrivateNew = MyDrawPrivateNew;
break;
case kQADrawPrivateDelete:
method->drawPrivateDelete = MyDrawPrivateDelete;
break;
case kQAEngineCheckDevice:
method->engineCheckDevice = MyEngineCheckDevice;
break;
case kQAEngineGestalt:
method->engineGestalt = MyEngineGestalt;
break;
case kQABitmapNew:
method->bitmapNew = MyBitmapNew;
break;
case kQABitmapDetach:
method->bitmapDetach = MyBitmapDetach;
break;
case kQABitmapDelete:
method->bitmapDelete = MyBitmapDelete;
break;
default:
return(kQANotSupported);
}
return(kQANoErr);
}
Finally, you register your drawing engine by passing the address of your TQAEngineGetMethod method to the QARegisterEngine function:
QARegisterEngine(&MyEngineGetMethod);
You can call QARegisterEngine in two ways. During product development, you can link your drawing engine code directly with a test application, in which case you should call QARegisterEngine from your application's initialization code. Alternatively, once you've completed development, you should build your engine's code into a shared library of type 'tnsl' . In this case, you should call QARegisterEngine from the initialization routine of the shared library. When the shared library containing QuickDraw 3D RAVE is loaded, it searches for and loads any drawing engines contained in shared libraries in the current folder or in the Extensions folder.
Previous | QD3D Book | Overview | Chapter Contents | Next |